package com.qijia.travel.domain.example;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.qijia.travel.common.Constants;
import com.qijia.travel.helper.DateHelper;
import com.qijia.travel.vo.GuideVO;

public class GuideExample extends BaseExample {

	protected String orderByClause;
	protected List<Criteria> oredCriteria;

	public GuideExample() {
		oredCriteria = new ArrayList<Criteria>();
	}

	protected GuideExample(GuideExample example) {
		this.orderByClause = example.orderByClause;
		this.oredCriteria = example.oredCriteria;
	}

	public void setOrderByClause(String orderByClause) {
		this.orderByClause = orderByClause;
	}

	public String getOrderByClause() {
		return orderByClause;
	}

	public List<Criteria> getOredCriteria() {
		return oredCriteria;
	}

	public void or(Criteria criteria) {
		oredCriteria.add(criteria);
	}

	public Criteria createCriteria(GuideVO guide) {
		Criteria criteria = createCriteriaInternal(guide);
		if (oredCriteria.size() == 0) {
			oredCriteria.add(criteria);
		}
		return criteria;
	}

	protected Criteria createCriteriaInternal(GuideVO guide) {
		Criteria criteria = new Criteria(guide);
		return criteria;
	}

	public void clear() {
		oredCriteria.clear();
	}

	public static class Criteria {
		protected List<String> criteriaWithoutValue;
		protected List<Map<String, Object>> criteriaWithSingleValue;
		protected List<Map<String, Object>> criteriaWithListValue;
		protected List<Map<String, Object>> criteriaWithBetweenValue;

		protected Criteria(GuideVO guide) {
			super();
			criteriaWithoutValue = new ArrayList<String>();
			criteriaWithSingleValue = new ArrayList<Map<String, Object>>();
			criteriaWithListValue = new ArrayList<Map<String, Object>>();
			criteriaWithBetweenValue = new ArrayList<Map<String, Object>>();

			if (guide != null) {
				if (guide.getSearchCode() != null 
						&& guide.getSearchCode() > 0 
						&& guide.getSearchKeyword() != null 
						&& guide.getSearchKeyword().trim().length()>0) {
					switch (guide.getSearchCode()) {
					case Constants.SEARCH_GUIDE_ID_CODE: {
						try {
							this.andGuideIdEqualTo(Integer.parseInt(guide
									.getSearchKeyword()));
						} catch (NumberFormatException e) {
							e.printStackTrace();
						}
					}
						;
						break;
					case Constants.SEARCH_GUIDE_TYPE_CODE: {
						try {
							this.andGuideTypeEqualTo(Integer.parseInt(guide
									.getSearchKeyword()));
						} catch (NumberFormatException e) {
							e.printStackTrace();
						}
					}
						;
						break;
					case Constants.SEARCH_GUIDE_NAME_CODE: {
							this.andGuideNameLike("%" + guide.getSearchKeyword() + "%");
					}
						;
						break;
					case Constants.SEARCH_STATUS_NAME_CODE: {
							this.andStatusNameLike("%" + guide.getSearchKeyword() + "%");
					}
						;
						break;
					case Constants.SEARCH_GUIDE_BELONGTO_CODE: {
						this.andBelongToLike("%" + guide.getSearchKeyword() + "%");
					}
						;
						break;
					default:
						break;
					}

				}

				if (guide.getTreamId() != null && guide.getTreamId() > 0) {
					this.andTreamIdEqualTo(guide.getTreamId());
				}

				if (guide.getDateCode() != null
						&& (guide.getStartDate() != null && guide
								.getStartDate().length() > 0)) {
					Calendar startDate = Calendar.getInstance();
					Calendar endDate = Calendar.getInstance();

					try {
						startDate.setTime(DateHelper.parseToDate(guide
								.getStartDate(), DateHelper.yyyyMMdd));
						if (guide.getEndDate() != null
								&& guide.getEndDate().length() > 0) {
							endDate.setTime(DateHelper.parseToDate(guide
									.getEndDate(), DateHelper.yyyyMMdd));
						}

						switch (guide.getDateCode()) {
						case Constants.DATETYPE_LOGIN_DATE_CODE: {
							this.andLoginDateGreaterThanOrEqualTo(startDate
									.getTime());
							this.andLoginDateLessThanOrEqualTo(endDate
									.getTime());
						}
							;
							break;
						case Constants.DATETYPE_REG_DATE_CODE: {
							this.andRegDateGreaterThanOrEqualTo(startDate
									.getTime());
							this.andRegDateLessThanOrEqualTo(endDate.getTime());
						}
							;
							break;
						default:
							break;
						}
					} catch (Exception e) {
					}

				}
			}
		}

		public boolean isValid() {
			return criteriaWithoutValue.size() > 0
					|| criteriaWithSingleValue.size() > 0
					|| criteriaWithListValue.size() > 0
					|| criteriaWithBetweenValue.size() > 0;
		}

		public List<String> getCriteriaWithoutValue() {
			return criteriaWithoutValue;
		}

		public List<Map<String, Object>> getCriteriaWithSingleValue() {
			return criteriaWithSingleValue;
		}

		public List<Map<String, Object>> getCriteriaWithListValue() {
			return criteriaWithListValue;
		}

		public List<Map<String, Object>> getCriteriaWithBetweenValue() {
			return criteriaWithBetweenValue;
		}

		protected void addCriterion(String condition) {
			if (condition == null) {
				throw new RuntimeException("Value for condition cannot be null");
			}
			criteriaWithoutValue.add(condition);
		}

		protected void addCriterion(String condition, Object value,
				String property) {
			if (value == null) {
				throw new RuntimeException("Value for " + property
						+ " cannot be null");
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("condition", condition);
			map.put("value", value);
			criteriaWithSingleValue.add(map);
		}

		protected void addCriterion(String condition,
				List<? extends Object> values, String property) {
			if (values == null || values.size() == 0) {
				throw new RuntimeException("Value list for " + property
						+ " cannot be null or empty");
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("condition", condition);
			map.put("values", values);
			criteriaWithListValue.add(map);
		}

		protected void addCriterion(String condition, Object value1,
				Object value2, String property) {
			if (value1 == null || value2 == null) {
				throw new RuntimeException("Between values for " + property
						+ " cannot be null");
			}
			List<Object> list = new ArrayList<Object>();
			list.add(value1);
			list.add(value2);
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("condition", condition);
			map.put("values", list);
			criteriaWithBetweenValue.add(map);
		}

		public Criteria andGuideIdIsNull() {
			addCriterion("guide_id is null");
			return this;
		}

		public Criteria andGuideIdIsNotNull() {
			addCriterion("guide_id is not null");
			return this;
		}

		public Criteria andGuideIdEqualTo(Integer value) {
			addCriterion("guide_id =", value, "guideId");
			return this;
		}

		public Criteria andGuideIdNotEqualTo(Integer value) {
			addCriterion("guide_id <>", value, "guideId");
			return this;
		}

		public Criteria andGuideIdGreaterThan(Integer value) {
			addCriterion("guide_id >", value, "guideId");
			return this;
		}

		public Criteria andGuideIdGreaterThanOrEqualTo(Integer value) {
			addCriterion("guide_id >=", value, "guideId");
			return this;
		}

		public Criteria andGuideIdLessThan(Integer value) {
			addCriterion("guide_id <", value, "guideId");
			return this;
		}

		public Criteria andGuideIdLessThanOrEqualTo(Integer value) {
			addCriterion("guide_id <=", value, "guideId");
			return this;
		}

		public Criteria andGuideIdIn(List<Integer> values) {
			addCriterion("guide_id in", values, "guideId");
			return this;
		}

		public Criteria andGuideIdNotIn(List<Integer> values) {
			addCriterion("guide_id not in", values, "guideId");
			return this;
		}

		public Criteria andGuideIdBetween(Integer value1, Integer value2) {
			addCriterion("guide_id between", value1, value2, "guideId");
			return this;
		}

		public Criteria andGuideIdNotBetween(Integer value1, Integer value2) {
			addCriterion("guide_id not between", value1, value2, "guideId");
			return this;
		}

		public Criteria andGuideNameIsNull() {
			addCriterion("guide_name is null");
			return this;
		}

		public Criteria andGuideNameIsNotNull() {
			addCriterion("guide_name is not null");
			return this;
		}

		public Criteria andGuideNameEqualTo(String value) {
			addCriterion("guide_name =", value, "guideName");
			return this;
		}

		public Criteria andGuideNameNotEqualTo(String value) {
			addCriterion("guide_name <>", value, "guideName");
			return this;
		}

		public Criteria andGuideNameGreaterThan(String value) {
			addCriterion("guide_name >", value, "guideName");
			return this;
		}

		public Criteria andGuideNameGreaterThanOrEqualTo(String value) {
			addCriterion("guide_name >=", value, "guideName");
			return this;
		}

		public Criteria andGuideNameLessThan(String value) {
			addCriterion("guide_name <", value, "guideName");
			return this;
		}

		public Criteria andGuideNameLessThanOrEqualTo(String value) {
			addCriterion("guide_name <=", value, "guideName");
			return this;
		}

		public Criteria andGuideNameLike(String value) {
			addCriterion("guide_name like", value, "guideName");
			return this;
		}

		public Criteria andGuideNameNotLike(String value) {
			addCriterion("guide_name not like", value, "guideName");
			return this;
		}

		public Criteria andGuideNameIn(List<String> values) {
			addCriterion("guide_name in", values, "guideName");
			return this;
		}

		public Criteria andGuideNameNotIn(List<String> values) {
			addCriterion("guide_name not in", values, "guideName");
			return this;
		}

		public Criteria andGuideNameBetween(String value1, String value2) {
			addCriterion("guide_name between", value1, value2, "guideName");
			return this;
		}

		public Criteria andGuideNameNotBetween(String value1, String value2) {
			addCriterion("guide_name not between", value1, value2, "guideName");
			return this;
		}

		public Criteria andGuideSexIsNull() {
			addCriterion("guide_sex is null");
			return this;
		}

		public Criteria andGuideSexIsNotNull() {
			addCriterion("guide_sex is not null");
			return this;
		}

		public Criteria andGuideSexEqualTo(String value) {
			addCriterion("guide_sex =", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexNotEqualTo(String value) {
			addCriterion("guide_sex <>", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexGreaterThan(String value) {
			addCriterion("guide_sex >", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexGreaterThanOrEqualTo(String value) {
			addCriterion("guide_sex >=", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexLessThan(String value) {
			addCriterion("guide_sex <", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexLessThanOrEqualTo(String value) {
			addCriterion("guide_sex <=", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexLike(String value) {
			addCriterion("guide_sex like", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexNotLike(String value) {
			addCriterion("guide_sex not like", value, "guideSex");
			return this;
		}

		public Criteria andGuideSexIn(List<String> values) {
			addCriterion("guide_sex in", values, "guideSex");
			return this;
		}

		public Criteria andGuideSexNotIn(List<String> values) {
			addCriterion("guide_sex not in", values, "guideSex");
			return this;
		}

		public Criteria andGuideSexBetween(String value1, String value2) {
			addCriterion("guide_sex between", value1, value2, "guideSex");
			return this;
		}

		public Criteria andGuideSexNotBetween(String value1, String value2) {
			addCriterion("guide_sex not between", value1, value2, "guideSex");
			return this;
		}

		public Criteria andMobileIsNull() {
			addCriterion("mobile is null");
			return this;
		}

		public Criteria andMobileIsNotNull() {
			addCriterion("mobile is not null");
			return this;
		}

		public Criteria andMobileEqualTo(String value) {
			addCriterion("mobile =", value, "mobile");
			return this;
		}

		public Criteria andMobileNotEqualTo(String value) {
			addCriterion("mobile <>", value, "mobile");
			return this;
		}

		public Criteria andMobileGreaterThan(String value) {
			addCriterion("mobile >", value, "mobile");
			return this;
		}

		public Criteria andMobileGreaterThanOrEqualTo(String value) {
			addCriterion("mobile >=", value, "mobile");
			return this;
		}

		public Criteria andMobileLessThan(String value) {
			addCriterion("mobile <", value, "mobile");
			return this;
		}

		public Criteria andMobileLessThanOrEqualTo(String value) {
			addCriterion("mobile <=", value, "mobile");
			return this;
		}

		public Criteria andMobileLike(String value) {
			addCriterion("mobile like", value, "mobile");
			return this;
		}

		public Criteria andMobileNotLike(String value) {
			addCriterion("mobile not like", value, "mobile");
			return this;
		}

		public Criteria andMobileIn(List<String> values) {
			addCriterion("mobile in", values, "mobile");
			return this;
		}

		public Criteria andMobileNotIn(List<String> values) {
			addCriterion("mobile not in", values, "mobile");
			return this;
		}

		public Criteria andMobileBetween(String value1, String value2) {
			addCriterion("mobile between", value1, value2, "mobile");
			return this;
		}

		public Criteria andMobileNotBetween(String value1, String value2) {
			addCriterion("mobile not between", value1, value2, "mobile");
			return this;
		}

		public Criteria andPhoneIsNull() {
			addCriterion("phone is null");
			return this;
		}

		public Criteria andPhoneIsNotNull() {
			addCriterion("phone is not null");
			return this;
		}

		public Criteria andPhoneEqualTo(String value) {
			addCriterion("phone =", value, "phone");
			return this;
		}

		public Criteria andPhoneNotEqualTo(String value) {
			addCriterion("phone <>", value, "phone");
			return this;
		}

		public Criteria andPhoneGreaterThan(String value) {
			addCriterion("phone >", value, "phone");
			return this;
		}

		public Criteria andPhoneGreaterThanOrEqualTo(String value) {
			addCriterion("phone >=", value, "phone");
			return this;
		}

		public Criteria andPhoneLessThan(String value) {
			addCriterion("phone <", value, "phone");
			return this;
		}

		public Criteria andPhoneLessThanOrEqualTo(String value) {
			addCriterion("phone <=", value, "phone");
			return this;
		}

		public Criteria andPhoneLike(String value) {
			addCriterion("phone like", value, "phone");
			return this;
		}

		public Criteria andPhoneNotLike(String value) {
			addCriterion("phone not like", value, "phone");
			return this;
		}

		public Criteria andPhoneIn(List<String> values) {
			addCriterion("phone in", values, "phone");
			return this;
		}

		public Criteria andPhoneNotIn(List<String> values) {
			addCriterion("phone not in", values, "phone");
			return this;
		}

		public Criteria andPhoneBetween(String value1, String value2) {
			addCriterion("phone between", value1, value2, "phone");
			return this;
		}

		public Criteria andPhoneNotBetween(String value1, String value2) {
			addCriterion("phone not between", value1, value2, "phone");
			return this;
		}

		public Criteria andTreamIdIsNull() {
			addCriterion("tream_id is null");
			return this;
		}

		public Criteria andTreamIdIsNotNull() {
			addCriterion("tream_id is not null");
			return this;
		}

		public Criteria andTreamIdEqualTo(Integer value) {
			addCriterion("tream_id =", value, "treamId");
			return this;
		}

		public Criteria andTreamIdNotEqualTo(Integer value) {
			addCriterion("tream_id <>", value, "treamId");
			return this;
		}

		public Criteria andTreamIdGreaterThan(Integer value) {
			addCriterion("tream_id >", value, "treamId");
			return this;
		}

		public Criteria andTreamIdGreaterThanOrEqualTo(Integer value) {
			addCriterion("tream_id >=", value, "treamId");
			return this;
		}

		public Criteria andTreamIdLessThan(Integer value) {
			addCriterion("tream_id <", value, "treamId");
			return this;
		}

		public Criteria andTreamIdLessThanOrEqualTo(Integer value) {
			addCriterion("tream_id <=", value, "treamId");
			return this;
		}

		public Criteria andTreamIdIn(List<Integer> values) {
			addCriterion("tream_id in", values, "treamId");
			return this;
		}

		public Criteria andTreamIdNotIn(List<Integer> values) {
			addCriterion("tream_id not in", values, "treamId");
			return this;
		}

		public Criteria andTreamIdBetween(Integer value1, Integer value2) {
			addCriterion("tream_id between", value1, value2, "treamId");
			return this;
		}

		public Criteria andTreamIdNotBetween(Integer value1, Integer value2) {
			addCriterion("tream_id not between", value1, value2, "treamId");
			return this;
		}

		public Criteria andStatusNameIsNull() {
			addCriterion("status_name is null");
			return this;
		}

		public Criteria andStatusNameIsNotNull() {
			addCriterion("status_name is not null");
			return this;
		}

		public Criteria andStatusNameEqualTo(String value) {
			addCriterion("status_name =", value, "statusName");
			return this;
		}

		public Criteria andStatusNameNotEqualTo(String value) {
			addCriterion("status_name <>", value, "statusName");
			return this;
		}

		public Criteria andStatusNameGreaterThan(String value) {
			addCriterion("status_name >", value, "statusName");
			return this;
		}

		public Criteria andStatusNameGreaterThanOrEqualTo(String value) {
			addCriterion("status_name >=", value, "statusName");
			return this;
		}

		public Criteria andStatusNameLessThan(String value) {
			addCriterion("status_name <", value, "statusName");
			return this;
		}

		public Criteria andStatusNameLessThanOrEqualTo(String value) {
			addCriterion("status_name <=", value, "statusName");
			return this;
		}

		public Criteria andStatusNameLike(String value) {
			addCriterion("status_name like", value, "statusName");
			return this;
		}

		public Criteria andStatusNameNotLike(String value) {
			addCriterion("status_name not like", value, "statusName");
			return this;
		}

		public Criteria andStatusNameIn(List<String> values) {
			addCriterion("status_name in", values, "statusName");
			return this;
		}

		public Criteria andStatusNameNotIn(List<String> values) {
			addCriterion("status_name not in", values, "statusName");
			return this;
		}

		public Criteria andStatusNameBetween(String value1, String value2) {
			addCriterion("status_name between", value1, value2, "statusName");
			return this;
		}

		public Criteria andStatusNameNotBetween(String value1, String value2) {
			addCriterion("status_name not between", value1, value2,
					"statusName");
			return this;
		}

		public Criteria andGuideTypeEqualTo(Integer value) {
			addCriterion("guide_type =", value, "guideType");
			return this;
		}

		public Criteria andRegDateIsNull() {
			addCriterion("reg_date is null");
			return this;
		}

		public Criteria andRegDateIsNotNull() {
			addCriterion("reg_date is not null");
			return this;
		}

		public Criteria andRegDateEqualTo(Date value) {
			addCriterion("reg_date =", value, "regDate");
			return this;
		}

		public Criteria andRegDateNotEqualTo(Date value) {
			addCriterion("reg_date <>", value, "regDate");
			return this;
		}

		public Criteria andRegDateGreaterThan(Date value) {
			addCriterion("reg_date >", value, "regDate");
			return this;
		}

		public Criteria andRegDateGreaterThanOrEqualTo(Date value) {
			addCriterion("reg_date >=", value, "regDate");
			return this;
		}

		public Criteria andRegDateLessThan(Date value) {
			addCriterion("reg_date <", value, "regDate");
			return this;
		}

		public Criteria andRegDateLessThanOrEqualTo(Date value) {
			addCriterion("reg_date <=", value, "regDate");
			return this;
		}

		public Criteria andRegDateIn(List<Date> values) {
			addCriterion("reg_date in", values, "regDate");
			return this;
		}

		public Criteria andRegDateNotIn(List<Date> values) {
			addCriterion("reg_date not in", values, "regDate");
			return this;
		}

		public Criteria andRegDateBetween(Date value1, Date value2) {
			addCriterion("reg_date between", value1, value2, "regDate");
			return this;
		}

		public Criteria andRegDateNotBetween(Date value1, Date value2) {
			addCriterion("reg_date not between", value1, value2, "regDate");
			return this;
		}

		public Criteria andLoginDateIsNull() {
			addCriterion("login_date is null");
			return this;
		}

		public Criteria andLoginDateIsNotNull() {
			addCriterion("login_date is not null");
			return this;
		}

		public Criteria andLoginDateEqualTo(Date value) {
			addCriterion("login_date =", value, "loginDate");
			return this;
		}

		public Criteria andLoginDateNotEqualTo(Date value) {
			addCriterion("login_date <>", value, "loginDate");
			return this;
		}

		public Criteria andLoginDateGreaterThan(Date value) {
			addCriterion("login_date >", value, "loginDate");
			return this;
		}

		public Criteria andLoginDateGreaterThanOrEqualTo(Date value) {
			addCriterion("login_date >=", value, "loginDate");
			return this;
		}

		public Criteria andLoginDateLessThan(Date value) {
			addCriterion("login_date <", value, "loginDate");
			return this;
		}

		public Criteria andLoginDateLessThanOrEqualTo(Date value) {
			addCriterion("login_date <=", value, "loginDate");
			return this;
		}

		public Criteria andLoginDateIn(List<Date> values) {
			addCriterion("login_date in", values, "loginDate");
			return this;
		}

		public Criteria andLoginDateNotIn(List<Date> values) {
			addCriterion("login_date not in", values, "loginDate");
			return this;
		}

		public Criteria andLoginDateBetween(Date value1, Date value2) {
			addCriterion("login_date between", value1, value2, "loginDate");
			return this;
		}

		public Criteria andLoginDateNotBetween(Date value1, Date value2) {
			addCriterion("login_date not between", value1, value2, "loginDate");
			return this;
		}
		
		public Criteria andBelongToIsNull() {
			addCriterion("belong_to is null");
			return this;
		}

		public Criteria andBelongToIsNotNull() {
			addCriterion("belong_to is not null");
			return this;
		}

		public Criteria andBelongToEqualTo(String value) {
			addCriterion("belong_to =", value, "belongTo");
			return this;
		}

		public Criteria andBelongToNotEqualTo(String value) {
			addCriterion("belong_to <>", value, "belongTo");
			return this;
		}

		public Criteria andBelongToGreaterThan(String value) {
			addCriterion("belong_to >", value, "belongTo");
			return this;
		}

		public Criteria andBelongToGreaterThanOrEqualTo(String value) {
			addCriterion("belong_to >=", value, "belongTo");
			return this;
		}

		public Criteria andBelongToLessThan(String value) {
			addCriterion("belong_to <", value, "belongTo");
			return this;
		}

		public Criteria andBelongToLessThanOrEqualTo(String value) {
			addCriterion("belong_to <=", value, "belongTo");
			return this;
		}

		public Criteria andBelongToLike(String value) {
			addCriterion("belong_to like", value, "belongTo");
			return this;
		}

		public Criteria andBelongToNotLike(String value) {
			addCriterion("belong_to not like", value, "belongTo");
			return this;
		}

		public Criteria andBelongToIn(List<String> values) {
			addCriterion("belong_to in", values, "belongTo");
			return this;
		}

		public Criteria andBelongToNotIn(List<String> values) {
			addCriterion("belong_to not in", values, "belongTo");
			return this;
		}

		public Criteria andBelongToBetween(String value1, String value2) {
			addCriterion("belong_to between", value1, value2, "belongTo");
			return this;
		}

		public Criteria andBelongToNotBetween(String value1, String value2) {
			addCriterion("belong_to not between", value1, value2,
					"belongTo");
			return this;
		}
	}
}